var t,
  e = require("../../utils/http.js"),
  a = require("../../utils/api.js"),
  n = require("../../utils/language/switchLanguage.js");
Page({
  data: {},
  onLoad: function (t) {
    this.setData({
      orderNo: t.orderNo,
      merchantNo: wx.getStorageSync("merchantNo"),
    }),
      this.initLanguage();
  },
  initLanguage: function () {
    var t = n.languageVersion(wx.getStorageSync("language"));
    this.setData({ _t: t, languageType: wx.getStorageSync("language") });
  },
  getOrderDetail: function (n) {
    var i = this;
    e.getOrderDetail(n).then(function (e) {
      var n = e.data;
      i.setData({ content: n }),
        (t = setInterval(function () {
          var n = a.CountDown(e.data.createTime);
          0 == n && clearInterval(t), i.setData({ countDown: n.split(":") });
        }, 1e3));
    });
  },
  wechatPay: function (t) {
    var n = {
        orderNo: this.data.orderNo,
        payConfigType: 1,
        tradeType: "wxSmallPay",
      },
      i = a.encryptBASE64(JSON.stringify(n)),
      o = { sign: a.autograph(i), signData: i };
    e.CreatePay(o).then(function (t) {
      wx.requestPayment({
        timeStamp: t.timeStamp,
        nonceStr: t.nonceStr,
        package: t.packageStr,
        signType: t.signType,
        paySign: t.paySign,
        success: function (t) {
          "requestPayment:ok" == t.errMsg &&
            (wx.showLoading({ title: this.data._t["支付处理中"] + "..." }),
            setTimeout(function () {
              wx.hideLoading(), wx.reLaunch({ url: "/pages/order-list/index" });
            }, 1e3));
        },
        fail: function (t) {
          "requestPayment:fail cancel" != t.errMsg &&
            "requestPayment:fail" != t.errMsg &&
            wx.showModal({
              title: this.data._t["通知"],
              showCancel: !1,
              content: this.data._t["调起支付失败，请稍后重试"] + "...",
              confirmText: this.data._t["确认"],
            });
        },
      });
    });
  },
  CancelOrder: function (t) {
    var n = t.currentTarget.dataset.orderno,
      i = this;
    wx.showModal({
      title: this.data._t["提示"],
      content: this.data._t["是否确认删除"],
      confirmText: i.data._t["确定"],
      cancelText: i.data._t["取消"],
      success: function (t) {
        if (t.confirm) {
          var o = { orderSn: n, merchantNo: i.data.merchantNo };
          wx.showLoading({ title: "取消中..." }),
            e.CancelOrder(o).then(function (t) {
              wx.hideLoading(),
                a.showMsg("取消成功"),
                wx.switchTab({ url: "/pages/index/index" });
            });
        }
      },
    });
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {
    clearInterval(t);
  },
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
  onShareAppMessage: function () {
    return { path: "/pages/index/index" };
  },
});
